<template>
  <view>
    <view class="font_style">和安这是随机生成的两个题哦！</view>
    <view v-for="item in num.list" class="span1">{{ data[item] }}</view>

    <button @click="resetQues" class="btn">重置题目</button>
  </view>
  <!-- 提示信息弹窗
  <uni-popup ref="message" type="message">
    <uni-popup-message
      :type="msgType"
      :message="messageText"
      :duration="2000"
    ></uni-popup-message>
  </uni-popup> -->
</template>

<script setup lang="ts">
import { onLoad, onShow } from "@dcloudio/uni-app";
import { onMounted, reactive, ref } from "vue";
let data = reactive([
  "1、集中量数",
  "2、差异量数",
  "3、积差相关",
  "4、等级相关",
  "5、质量相关和品质相关",
  "6、二项分布和抽样分布",
  "7、参数估计",
  "8、平均数显著性检验",
  "9、平均数差异显著性检验",
  "10、方差差异显著性检验",
  "11、相关系数差异显著性检验",
  "12、拟合度检验",
  "13、独立性检验",
  "14、独立样本非参数检验",
  "15、配对样本非参数检验",
  "16、等级方差分析",
  "17、建立相关方程的方法及相关系数和回归系数的关系",
  "18、方程的有效性检验",
  "19、回归系数的显著性检验",
  "20、决定系数",
  "21、单因素完全随机设计方差分析",
  "22、随机区组设计的方差分析",
  "23、二因素完全随机设计方差分析",
  "24、两因素混合实验设计的方差分析",
  "25、两因素被试内实验设计的方差分析",
]);
const handleData: any = reactive({
  list: [...data],
});
let num: any = reactive({
  list: [],
});
let nn = ref<number>(0);
const props = defineProps<{
  num: Number;
}>();
onLoad((option) => {
  console.log(option?.num == "1");
  if (option?.num == 0) {
    nn.value = 2;
  } else if (option?.num == 1) {
    nn.value = 4;
  } else if (option?.num == 2) {
    nn.value = 6;
  } else {
    nn.value = 25;
  }
});
let cacheNums: any = [];

const resetQues = () => {
  let nums = [] as any;
  for (var i = 0; i < nn.value; i++) {
    nums[i] = Math.floor(Math.random() * 25); //范围是[1~20]
    for (var j = 0; j < i; j++) {
      if (nums[i] == nums[j]) {
        i--;
      }
    }
  }
  num.list = [];
  num.list.push(...nums);
};
onMounted(() => {
  uni.showToast({
    title: "题目已生成",
    icon: "success",
    duration: 2000,
  });
  (() => {
    let nums: any[] = [];
    for (var i = 0; i < nn.value; i++) {
      nums[i] = Math.floor(Math.random() * 25); //范围是[1~10]
      for (var j = 0; j < i; j++) {
        if (nums[i] == nums[j]) {
          i--;
        }
      }
    }
    num.list.push(...nums);
    //   cacheNums.push(...nums);
  })();
  console.log(nn.value);
});
</script>

<style scoped lang="scss">
.font_style {
  font-family: "Times New Roman", Times, serif;
  color: #000;
  font-weight: 700;
  margin-bottom: 30rpx;
}
.span1 {
  font-family: "Times New Roman", Times, serif;
  color: #666;
  font-weight: 600;
  margin: 30rpx 30rpx;
}
.btn {
  width: 50%;
  color: #fff;
  background-color: $uni-color-primary;
}
</style>
